package org.example.sort;

import org.example.innerclass.A;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class DouDiZhu {
    public static void main(String[] args) {
//        1.创建ArrayList集合-> color -> 专门存花色
        List<String> color = new ArrayList<>();
        Collections.addAll(color,"红桃","方片","黑桃","梅花");
//        2.创建一个ArrayList集合 -> number -> 专门存牌号
        List<String> number = new ArrayList<>();
        for(int i=2;i<=10;i++){
            number.add(i+"");
        }
        Collections.addAll(number,"J","Q","K","A");
//        3.创建一个ArrayList集合 -> poker -> 专门存花色和牌号组合好的牌面
        List<String> poker = new ArrayList<>();
        for(String c:color){
            for(String n:number) {
                poker.add(c + ":" + n);
            }
        }
        Collections.addAll(poker,"小王","大王");
        System.out.println(poker.size());
//        4.打乱poker
        Collections.shuffle(poker);
        System.out.println(poker);
//        5.创建4个ArrayList集合,分别代表三个玩家,以及存储一个底牌
        List<String> p1 = new ArrayList<>();
        List<String> p2 = new ArrayList<>();
        List<String> p3 = new ArrayList<>();
        List<String> dipai = new ArrayList<>();
        dipai.addAll(poker.subList(poker.size()-3,poker.size()));
        System.out.println(dipai);
        for (int i = 0; i < poker.size()-dipai.size(); i++) {
            if(i%3==0){
                p1.add(poker.get(i));
            }else if(i%3==1){
                p2.add(poker.get(i));
            }else if(i%3==2){
                p3.add(poker.get(i));
            }
        }
//        6.如果index为最后三张,往dipai集合中存
//        7.如果index%3==0 给p1
//        8.如果index%3==1 给p2
//        9.如果index%3==2 给p3
//        10.遍历看牌
        System.out.println(p1);
        System.out.println(p2);
        System.out.println(p3);
        System.out.println(dipai);
    }
}
